package com.example.quartz.core;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * spring容器根据类型获取Bean
 * @author xw
 * @data 2017年3月31日17:34:39
 *
 */
@Component
public class SpringGetService implements ApplicationContextAware {

	private static ApplicationContext applicationContext;
	
	public static<T>T getBean(Class<T> clazz){
		return applicationContext.getBean(clazz);
	}

	@Override
	public void setApplicationContext(ApplicationContext ctx) throws BeansException {
		applicationContext = ctx;
	}

}
